package cn.tedu.egmvc6.base.exception;

import cn.tedu.egmvc6.base.response.JsonResult;
import cn.tedu.egmvc6.base.response.StateCode;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice

public class GlobalExceptionHandler {
    @ExceptionHandler
    public JsonResult doHandleMethodArgumentNotValidException(MethodArgumentNotValidException e){
        String data = e.getMessage();
        return new JsonResult(StateCode.VALIDATED_ERROR,data);
    }
}
